-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support async bulk api #90
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #90 +/- ##
========================================
+ Coverage 97.5% 97.7% +0.2%
========================================
Files 7 7
Lines 440 522 +82
Branches 78 94 +16
========================================
+ Hits 429 510 +81
Misses 7 7
- Partials 4 5 +1
Continue to review full report at Codecov.
|
Thanks for the contribution! Can You add some tests? |
This project still support Python 3.5.3-, can You pass everywhere explicit loop? |
aioelasticsearch/helpers.py
Outdated
@@ -147,3 +150,121 @@ def _update_state(self, resp): | |||
self._successful_shards = resp['_shards']['successful'] | |||
self._total_shards = resp['_shards']['total'] | |||
self._done = not self._hits or self._scroll_id is None | |||
|
|||
|
|||
async def worker_bulk(client, datas: List[dict], actions: List[str], **kwargs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All project do not provide yet typings everywhere, so it not makes to put them here. Later typings will be provided everywhere...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can You make travis green?
aioelasticsearch/helpers.py
Outdated
async def _retry_handler(client, futures, max_retries, initial_backoff, | ||
max_backoff, **kwargs): | ||
finish = 0 | ||
for attempt in range(max_retries + 1): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have You copied this implementation from original library?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, i ported the code from https://github.com/elastic/elasticsearch-py/blob/master/elasticsearch/helpers/__init__.py#L182
aioelasticsearch/helpers.py
Outdated
sleep = min(max_backoff, initial_backoff * 2 ** (attempt - 1)) | ||
await asyncio.sleep(sleep) | ||
|
||
results = await asyncio.gather(*futures, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This gather produces unexpected load, not sure, but maybe it should be rewritten in asyncio.queue
/ workers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
provide please explicit loop
aioelasticsearch/helpers.py
Outdated
for attempt in range(max_retries + 1): | ||
if attempt: | ||
sleep = min(max_backoff, initial_backoff * 2 ** (attempt - 1)) | ||
await asyncio.sleep(sleep) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
provide please explicit loop
Ok, I am refactoring |
from aioelasticsearch import Elasticsearch | ||
from aioelasticsearch.helpers import bulk | ||
|
||
def gen_data(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about to make it async gen? It Should be really usefull
I stumbled upon this because I need bulk in a asyncio project. What is the current status of this PR? Is there a particular reason why it was never merged? |
^^ Bulk is a really critical part of working with ES, any estimate for this? |
feature async bulk api